package com.example.demo.vo

import com.example.demo.dao.TBoardMessageDao
import com.example.demo.dbmodels.TBoardMessage
import io.swagger.annotations.ApiModelProperty
import me.liuwj.ktorm.dsl.QueryRowSet

class BoardMessageVo {

    @ApiModelProperty(value = "id")
    var id: Int? = null

    @ApiModelProperty(value = "科室Id")
    var deptId: Int? = null

    @ApiModelProperty(value = "消息类型")
    var messageType: String? = null

    @ApiModelProperty(value = "消息")
    var message: String? = null

    @ApiModelProperty(value = "消息日期")
    var date: String? = null


    fun getVo(queue: QueryRowSet): BoardMessageVo {
        queue.let {
            val boardMessageVo = BoardMessageVo()
            boardMessageVo.id = it[TBoardMessageDao.id]
            boardMessageVo.date = it[TBoardMessageDao.date]
            boardMessageVo.deptId = it[TBoardMessageDao.deptId]
            boardMessageVo.message = it[TBoardMessageDao.message]
            boardMessageVo.messageType = it[TBoardMessageDao.messageType]
            return boardMessageVo
        }
    }

    fun getVoList(table: List<TBoardMessage>): List<BoardMessageVo> {
        table.let {
            val dataList = mutableListOf<BoardMessageVo>()
            it.forEach {
                val data = BoardMessageVo()
                data.id = it.id
                data.date = it.date
                data.deptId = it.deptId
                data.message = it.message
                data.messageType = it.messageType
                dataList.add(data)
            }
            return dataList
        }
    }
}